<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #dv1 {
            width: 200px;
            height: 200px;
            background-color: black;
            color: #ffff;
            margin: 150px auto 0px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #dv1 #dv2 {
            width: 80%;
            height: 80%;
            background-color: black;
        }
    </style>
</head>

<body>
    <div id="dv1">
        <div id="dv2"> 鼠标移入改变样式，鼠标移出恢复</div>
    </div>
</body>
<script>
    var odv1 = document.getElementById("dv1");
    var odv2 = document.getElementById("dv2");
    odv1.onmouseover = function () {
        console.log("移入");
        odv1.style.backgroundColor = 'red'
        odv2.style.backgroundColor = '#ffff'
        odv2.style.color = 'red'
    }
    odv1.onmouseout = function () {
        console.log("移出");
        odv1.style = ''
        odv2.style = ''
    }
</script>

</html>